<?php

namespace app\controller\admin\sky;

use app\model\api\SkyActivity;
use app\model\api\SkyAncestor;
use laytp\controller\Backend;
use laytp\library\CommonFun;
use think\facade\Db;
use think\response\Json;

/**
 * Class Ancestor
 * @package app\controller\admin\sky
 */
class Ancestor extends Backend
{
    /**
     *
     * @var Ancestor
     */
    protected $model;
    protected $hasSoftDel=0;//是否拥有软删除功能

    protected $noNeedLogin = []; // 无需登录即可请求的方法
    protected $noNeedAuth = ['index', 'info']; // 无需鉴权即可请求的方法

    public $orderRule = ['id' => 'asc'];

    public function _initialize()
    {
        $this->model = new SkyAncestor();
    }


    /**
     * 列表
     *  all_data参数的值为true时，表示查询表中所有数据集，否则进行分页查询
     * @return mixed
     */
    public function index()
    {
        $where   = $this->buildSearchParams();
        $order   = $this->buildOrder();
        $allData = $this->request->param('all_data');
        if ($allData) {
            $data = $this->model->where($where)->order($order)->cache(true)->select()->toArray();
        } else {
            $limit = $this->request->param('limit', 10);
            $data  = $this->model->where($where)->order($order)->paginate($limit)->toArray();
        }
        return $this->success('数据获取成功', $data);
    }
}